<?php
/**
 * @package   auto_occasion
 * @subpackage 
 * @author    CMS
 * @copyright  2011
 * @license    All rights reserved
 */

class superbofSrv {

     /**
     * Fonction permettant de sauvegarder les superbofs d'un essai
     * @return object $superbof
     *
     */
    public function ajouter ($superbof) {
 
		// instanciation de la factory
        $maFactory = jDao::get("commun~ao_appreciation");
        $records   = jDao::createRecord("commun~ao_appreciation");

        $records->apprec_plus           = $superbof['apprec_plus'];
        $records->apprec_moins          = $superbof['apprec_moins'];
        $records->apprec_essai_id       = $superbof['iId'];

         if ($maFactory->insert($records)) {
            return $records->apprec_id;
        }

    }
     /**
     * Fonction permettant de modifier les superbofs d'un essai
     * @return object $partenaire
     *
     */
    public function modifier ($superbof) {
        // instanciation de la factory
        $maFactory = jDao::get("commun~ao_appreciation");
        $records   = $maFactory->get($superbof['id']);

        $records->apprec_plus           = $superbof['apprec_plus'];
        $records->apprec_moins          = $superbof['apprec_moins'];
        $records->apprec_essai_id       = $superbof['iId'];

        if ($maFactory->update($records)) {
            return $superbof['id'];
        }

    }
    /**
     * Fonction permettant de modifier les superbofs d'un essai
     * @return object $partenaire
     *
     */
    public function chargeParEssaiId ($essaiId) {
		$sql = " SELECT * FROM ao_appreciation WHERE apprec_essai_id =".$essaiId;
        $jdb = jDb::getDbWidget();
        $result  =  $jdb->fetchAll($sql);
        return $result;
        }

   
}